export function tableColumns() {
  const self = this
  const _getOperateLinkDisabled = function(self, row = {}) {
    return !self.hasPermission('DATA-ELEMENTS-WRITE')
  }
  const _getCheckLinkDisabled = function(self, row = {}) {
    return !self.hasPermission('DATA-ELEMENTS-READ')
  }
  return [
    {
      title: '报表名称', // 应用名称
      key: 'name'
      // sortable: "custom"
    },
    {
      title: '操作',
      align: 'left',
      fixed: 'right',
      width: 160,
      render: (h, params) => {
        return h('RowTools', {
          props: {
            data: [
              {
                type: 'text',
                text: '操作',
                // hidden: !_getOperateLinkPermisson(self, params.row), //是否显示隐藏操作按钮
                optType: _getOperateLinkDisabled(self, params.row) ? 'ashing' : '',
                handle: () => {
                  this.codeTest()
                }
              },
              {
                type: 'text',
                text: '查看',
                // hidden: !_getCheckLinkPermisson(self, params.row),
                optType: _getCheckLinkDisabled(self, params.row) ? 'ashing' : '',
                handle: () => {
                  this.managementFun(params.row)
                }
              },
              {
                type: 'text',
                text: '汇总报表',
                // hidden: !_getStatisticsLinkPermisson(self, params.row),
                handle: () => {
                  if (params.row.id == 1) {
                    this.statisticsFun(params.row)
                  }
                }
              }
            ]
          }
        })
      }
    }
  ]
}

export function columnList(isView = false) {
  return [
    {
      title: '业务单元',
      key: 'buCode',
      render: (h, params) => {
        const item = this.$store.state.buList.filter(item => item.key === params.row.buCode)[0]
        return h('span', item.value)
      }
    },
    { title: '填报人', key: 'creator' },
    {
      title: '状态',
      key: 'status',
      render: (h, params) => {
        return h('div', [h('p', params.row.status == 1 ? '待提交' : params.row.status == 2 ? '已提交' : '已审核')])
      }
    },
    { title: '最后更新时间', key: 'updateTime', minWidth: 160 },
    {
      title: '操作',
      align: 'left',
      fixed: 'right',
      width: 180,
      render: (h, params) => {
        return h('RowTools', {
          props: {
            data: [
              {
                type: 'text',
                text: '详情',
                // optType: isView && params.row.status === 1 ? 'ashing' : '',
                handle: () => {
                  this.goDetail(params.row)
                }
              },
              {
                type: 'text',
                text: '编辑',
                hidden: isView,
                optType: params.row.status === 1 ? '' : 'ashing',
                handle: () => {
                  this.goEdit(params.row)
                }
              },
              {
                type: 'text',
                text: params.row.status == 3 ? '查看审批记录' : '审批',
                hidden: !isView,
                optType: params.row.processId ? '' : 'ashing',
                handle: () => {
                  this.goApproval(params.row)
                }
              }
            ]
          }
        })
      }
    }
  ]
}
